<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/17
  Time: 19:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="JS/jquery-1.8.3.js"></script>
    <script src="CSS/bootstrap.min.js"></script>
    <link rel="stylesheet" href="CSS/bootstrap.css">
    <style>
        form {
            width: 700px;
            margin: 0 auto;
        }

        select.input-sm {
            height: 30px;
            line-height: 30px;
            width: 580px;
        }
    </style>

</head>
<body>

<h3 style="text-align: center ">帖子修改</h3>

<form class="form-horizontal" role="form">
    <div class="form-group">
        <label for="inputEmail4" class="col-sm-2 control-label">板块ID</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="bId" id="inputEmail4" placeholder="板块ID"
                   value="${requestScope.bId}" readonly="readonly">
        </div>
    </div>
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">主贴标题</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="title" id="inputEmail3" placeholder="主贴标题"
                   value="${requestScope.title}" readonly="readonly">
        </div>
    </div>
    <div class="form-group">
        <label for="selectBlank" class="col-sm-2 control-label">板块名称</label>
        <div class="col-sm-10">
            <select id="selectBlank" class="form-control input-sm">
                <option>---板块---</option>
                <c:forEach items="${requestScope.blank}" var="t" varStatus="s">
                    <option value="${t.bId}">${t.bName}</option>
                </c:forEach>
            </select>
        </div>
    </div>


    <label for="textarea" class="col-sm-2 control-label">帖子内容</label>
    <textarea style="width: 578px" id="textarea" class="form-control" name="text" rows="3"
              placeholder="请输入帖子内容"></textarea>


    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default">修改</button>
            <a href="javascript:history.go(-1)" class="btn btn-default">返回</a>
        </div>
    </div>
</form>


</body>

<script>
    $.ajax({
            type: "post",
            url: "GetTopicInfoByAjaxServlet",
            dataType: "JSON",
            data: {bId: $("#inputEmail4").val(), title: $("#inputEmail3").val()},
            success: function (data) {
                $.each(data, function (index, obj) {
                    $("#textarea").val(obj.context);
                })
            }
        }
    );

    $(function () {
        var id = ${requestScope.topicList[0].blank.bId};
        $("#selectBlank [value=" + id + "]").attr("selected", true);
    })
</script>

</html>
